package com.obtk.service.impl;

import com.obtk.mapper.CustomerServerMapper;
import com.obtk.modelSGW.CstServer;
import com.obtk.service.CustomerServerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CustomerServerServiceImpl implements CustomerServerService {

    @Autowired
    private CustomerServerMapper customerServerMapper;

    @Override
    public List<CstServer> getCstServer(CstServer cstServer) {
        return customerServerMapper.getCstServer(cstServer);
    }

    // 新增客户服务
    public int addCstServer(CstServer cstServer) {
        cstServer.setSvrStatus(0);
        cstServer.setSvrCreateDate(new Date());
        return customerServerMapper.insert(cstServer);
    }

    // 分配客户服务
    @Override
    public int distribute(CstServer cstServer, String[] svrIdsList) {
        cstServer.setSvrStatus(1);//1为已分配状态
        cstServer.setSvrCreateDate(new Date());//赋值当前时间
        Map<String, Object> map = new HashMap<>();
        map.put("svrIdsList", svrIdsList);
        map.put("cstServer", cstServer);
        return customerServerMapper.distribute(map);
    }

    // 更改状态
    public int changeStatus(CstServer cstServer, String[] svrIdsList) {
        Map<String, Object> map = new HashMap<>();
        map.put("svrIdsList", svrIdsList);
        map.put("cstServer", cstServer);
        return customerServerMapper.changeStatus(map);
    }

    // 服务处理
    public int dealWith(CstServer cstServer, String[] svrIdsList) {
        cstServer.setSvrDealDate(new Date());
        System.out.println(cstServer);
        Map<String, Object> map = new HashMap<>();
        map.put("svrIdsList", svrIdsList);
        map.put("cstServer", cstServer);
        return customerServerMapper.dealWith(map);
    }

    //服务归档
    public int placeOnFile(CstServer cstServer, String[] svrIdsList) {
        Map<String, Object> map = new HashMap<>();
        map.put("svrIdsList", svrIdsList);
        map.put("cstServer", cstServer);
        return customerServerMapper.placeOnFile(map);
    }
}